#include <iostream>
using namespace std;

class Cat
{
public:
    Cat(string name, int age, float weight)
    {
        this->name = name;
        this->age = age;
        this->weight = weight;
        cout << "有参构造函数" << endl;
    }
    Cat()
    {
        cout << "无参构造函数" << endl;
    }

    Cat(const Cat &cat)
    {
        cout << "拷贝构造函数" << endl;
        this->name = cat.name;
        this->age = cat.age;
        this->weight = cat.weight;
    }

    void show()
    {
        cout << "name:" << name << endl;
        cout << "age:" << age << endl;
        cout << "weight:" << weight << endl;
    }

private:
    string name;
    int age;
    float weight;
};

int main()
{
    // 创建猫对象
    Cat c1("旺财", 5, 15.5);
    // 写法1
    Cat c2 = c1; // 调用拷贝构造函数
    // 写法2
    Cat c3(c1); // 调用拷贝构造函数
    // 写法3
    Cat c4 = Cat(c1); // 调用拷贝构造函数
    // 写法4,跟写法3类似
    Cat *c5 = new Cat(c1); // 调用拷贝构造函数
    delete c5;
    return 0;
}
